import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { DingdDeptInfoApi } from '#/api/moxi/dingdattendanceinfo';

import { handleTree } from '@vben/utils';

import { z } from '#/adapter/form';
import { getDeptList } from '#/api/system/dept';
import { getSimplePostList } from '#/api/system/post';
import { getSimpleRoleList } from '#/api/system/role';
import {
  CommonStatusEnum,
  DICT_TYPE,
  getDictOptions,
  getRangePickerDefaultProps,
} from '#/utils';
import dayjs from 'dayjs';








/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'name',
      label: '员工姓名',
      component: 'Input',
      componentProps: {
        placeholder: '请输入员工姓名',
        allowClear: true,
      },
    },
    {
      fieldName: 'attendMonth',
      label: '考勤月份',
      component: 'DatePicker',
      defaultValue: dayjs().format('YYYY-MM'), // 初始值为字符串格式
      componentProps: {
        picker: 'month', // 指定为月份选择器
        allowClear: true,
        defaultValue: dayjs(), 
        valueFormat: 'YYYY-MM',
        format: 'YYYY-MM', 
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns<T = DingdDeptInfoApi.tableInfo>(
  onStatusChange?: (
    newStatus: number,
    row: T,
  ) => PromiseLike<boolean | undefined>,
): VxeTableGridOptions['columns'] {
  return [
    // {
    //   field: 'id',
    //   title: '序号',
    //   formatter: ({ cellValue }) => {
    //     console.log('cellValue');
        
    //     console.log(cellValue);
    //     return cellValue || '-';
    //   },
    // },
    {
      field: 'name',
      title: '员工姓名',
    },
    {
      field: 'avatar',
      title: '头像',
      cellRender: {
        name: 'CellImage',
      },
    },
    {
      field: 'mobile',
      title: '手机号',
    },
    {
      field: 'jobNumber',
      title: '工号',
    },
    {
      field: 'title',
      title: '职位',
    },
    {
      field: 'shouldAttendanceDays',
      title: '应出勤天数',
    },
    {
      field: 'attendanceDays',
      title: '出勤天数',
    },
    {
      field: 'absenteeismDays',
      title: '旷工天数',
    },
    {
      field: 'makingUpLackTimes',
      title: '补卡次数',
    },
    {
      field: 'attendanceRestDays',
      title: '休息天数',
    },
    {
      field: 'attendResult',
      title: '考勤结果',
    },
    {
      title: '操作',
      width: 180,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
